/*******************************************OVERVIEW*******************************************************
 
 Political Shocks and Asset Prices
 
 Replication do file
 
 Appendix F
 
 Version July 29 2021 
 
  
********************************************************************************************************************/


clear
set more off
#delimit ;

cd "/Users/ssaiegh/Files/Mac/UCSD/Carnahan/Shocks/Replication Files";

log using "Appendix F", replace text;

/*Figure F1. Average Volatility Ratios*/;


use "daily_sp_argentina_2020.dta";

gen case_id= _n;

tsset case_id;

gen event=(steward==1 | gov_change==1 | dem_change==1 | elec==1 | terror==1);

gen ret_nom=log(nominal/L.nominal);
arch ret_nom ret_sp, arch(1) garch(1) vce(robust);
predict var_nom, var;
gen ratio_nom=log(F.var_nom/var_nom);

mswitch dr ret_nom;
predict fprob, pr smethod(filter);
estat duration; 
tssmooth ma state = fprob, window(89 1 89);
gen dummy=(state<.98);

arch ret_nom ret_sp, arch(1) garch(1) het(dummy) vce(robust);
predict het_var, var;
gen ratio_het=log(F.het_var/het_var);

drop if ratio_het==.;

gen ret_inf=log(inflation/L.inflation);
arch ret_inf ret_sp_real, arch(1) garch(1) het(dummy) vce(robust);
predict het_inf, var;
gen ratio_het_inf=log(F.het_inf/het_inf);
drop if ratio_het_inf==.;

gen ret_dol=log(dollar/L.dollar);
arch ret_dol ret_sp_real, arch(1) garch(1) het(dummy) vce(robust);
predict het_dol, var;
gen ratio_het_dol=log(F.het_dol/het_dol);
drop if ratio_het_dol==.;


keep if event==1 | F.event==1;

collapse (mean) mean_nom=ratio_het (sem) sd_nom=ratio_het (mean) mean_inf=ratio_het_inf (sem) sd_inf=ratio_het_inf (mean) mean_dol=ratio_het_dol (sem) sd_dol=ratio_het_dol, by(event);
generate hi_nom = mean_nom + 1.69340048 *(sd_nom);
generate lo_nom = mean_nom -2.4312129 *(sd_nom);
generate hi_inf = mean_inf + 1.69340048 *(sd_inf);
generate lo_inf = mean_inf -2.4312129 *(sd_inf);
generate hi_dol = mean_dol + 1.69340048 *(sd_dol);
generate lo_dol = mean_dol -2.4312129 *(sd_dol);


twoway (bar mean_nom event) (rcap hi_nom lo_nom event), name(nom);
twoway (bar mean_inf event) (rcap hi_inf lo_inf event), name(inf);
twoway (bar mean_dol event) (rcap hi_dol lo_dol event), name(dol);

graph combine nom inf dol, col(3);

graph drop nom;
graph drop inf;
graph drop dol;

/*Figure F2 Q-Q (quantile-quantile) plots*/;


use "daily_sp_argentina_2020.dta", clear;

gen case_id= _n;

tsset case_id;

gen event=(steward==1 | gov_change==1 | dem_change==1 | elec==1 | terror==1);


gen hiper=(year>1981 & year<1992);

gen ret_nom=log(nominal/L.nominal);
arch ret_nom ret_sp, arch(1) garch(1) vce(robust);
predict var_nom, var;
gen ratio_nom=log(F.var_nom/var_nom);


arch ret_nom ret_sp, arch(1) garch(1) atarch(1) vce(robust);
predict var_anom, var;
gen ratio_anom=log(F.var_anom/var_anom);

qqplot ratio_anom ratio_nom, name(atarch);


arch ret_nom ret_sp, earch(1) egarch(1) vce(robust);
predict var_enom, var;
gen ratio_enom=log(F.var_enom/var_enom);

qqplot ratio_enom ratio_nom, name(egarch);

graph combine atarch egarch, col(2);

graph drop atarch;

graph drop egarch;

log c;

